home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
mint
/
mint104s.zoo
/
mint.src
/
file.h
< prev
next >
Wrap
C/C++ Source or Header
|
1993-03-08
|
17KB
|
526 lines
/*
Copyright 1991,1992 Eric R. Smith.
Copyright 1992 Atari Corporation.
All rights reserved.
*/
#ifndef _filesys_h
#define _filesys_h
struct filesys; /* forward declaration */
struct devdrv; /* ditto */
typedef struct f_cookie {
struct filesys *fs; /* filesystem that knows about this cookie */
ushort dev; /* device info (e.g. Rwabs device number) */
ushort aux; /* extra data that the file system may want */
long index; /* this+dev uniquely identifies a file */
} fcookie;
#define TOS_NAMELEN 13
typedef struct dtabuf {
short index; /* index into arrays in the PROC struct */
long magic;
#define SVALID 0x1234fedcL /* magic for a valid search */
#define EVALID 0x5678ba90L /* magic for an exhausted search */
char dta_pat[TOS_NAMELEN+1]; /* pointer to pattern, if necessary */
char dta_sattrib; /* attributes being searched for */
/* this stuff is returned to the user */
char dta_attrib;
short dta_time;
short dta_date;
long dta_size;
char dta_name[TOS_NAMELEN+1];
} DTABUF;
/* structure for opendir/readdir/closedir */
typedef struct dirstruct {
fcookie fc; /* cookie for this directory */
ushort index; /* index of the current entry */
ushort flags; /* flags (e.g. tos or not) */
#define TOS_SEARCH 0x01
char fsstuff[60]; /* anything else the file system wants */
/* NOTE: this must be at least 45 bytes */
struct dirstruct *next; /* linked together so we can close them
on process termination */
} DIR;
/* structure for getxattr */
typedef struct xattr {
ushort mode;
/* file types */
#define S_IFMT 0170000 /* mask to select file type */
#define S_IFCHR 0020000 /* BIOS special file */
#define S_IFDIR 0040000 /* directory file */
#define S_IFREG 0100000 /* regular file */
#define S_IFIFO 0120000 /* FIFO */
#define S_IMEM 0140000 /* memory region or process */
#define S_IFLNK 0160000 /* symbolic link */
/* special bits: setuid, setgid, sticky bit */
#define S_ISUID 04000
#define S_ISGID 02000
#define S_ISVTX 01000
/* file access modes for user, group, and other*/
#define S_IRUSR 0400
#define S_IWUSR 0200
#define S_IXUSR 0100
#define S_IRGRP 0040
#define S_IWGRP 0020
#define S_IXGRP 0010
#define S_IROTH 0004
#define S_IWOTH 0002
#define S_IXOTH 0001
#define DEFAULT_DIRMODE (0777)
#define DEFAULT_MODE (0666)
long index;
ushort dev;
ushort reserved1;
ushort nlink;
ushort uid;
ushort gid;
long size;
long blksize;
long nblocks;
short mtime, mdate;
short atime, adate;
short ctime, cdate;
short attr;
/* defines for TOS attribute bytes */
#ifndef FA_RDONLY
#define FA_RDONLY 0x01
#define FA_HIDDEN 0x02
#define FA_SYSTEM 0x04
#define FA_LABEL 0x08
#define FA_DIR 0x10
#define FA_CHANGED 0x20
#endif
short reserved2;
long reserved3[2];
} XATTR;
typedef struct fileptr {
short links; /* number of copies of this descriptor */
ushort flags; /* file open mode and other file flags */
long pos; /* position in file */
long devinfo; /* device driver specific info */
fcookie fc; /* file system cookie for this file */
struct devdrv *dev; /* device driver that knows how to deal with this */
struct fileptr *next; /* link to next fileptr for this file */
} FILEPTR;
struct flock {
short l_type; /* type of lock */
#define F_RDLCK 0
#define F_WRLCK 1
#define F_UNLCK 3
short l_whence; /* SEEK_SET, SEEK_CUR, SEEK_END */
long l_start; /* start of locked region */
long l_len; /* length of locked region */
short l_pid; /* pid of locking process
(F_GETLK only) */
};
/* structure for internal kernel locks */
typedef struct ilock {
struct flock l; /* the actual lock */
struct ilock *next; /* next lock in the list */
long reserved[4]; /* reserved for future expansion */
} LOCK;
typedef struct devdrv {
long ARGS_ON_STACK (*open) P_((FILEPTR *f));
long ARGS_ON_STACK (*write) P_((FILEPTR *f, const char *buf, long bytes));
long ARGS_ON_STACK (*read) P_((FILEPTR *f, char *buf, long bytes));
long ARGS_ON_STACK (*lseek) P_((FILEPTR *f, long where, int whence));
long ARGS_ON_STACK (*ioctl) P_((FILEPTR *f, int mode, void *buf));
long ARGS_ON_STACK (*datime) P_((FILEPTR *f, short *timeptr, int rwflag));
long ARGS_ON_STACK (*close) P_((FILEPTR *f, int pid));
long ARGS_ON_STACK (*select) P_((FILEPTR *f, long proc, int mode));
void ARGS_ON_STACK (*unselect) P_((FILEPTR *f, long proc, int mode));
} DEVDRV;
typedef struct filesys {
struct filesys *next; /* link to next file system on chain */
long fsflags;
#define FS_KNOPARSE 0x01 /* kernel shouldn't do parsing */
#define FS_CASESENSITIVE 0x02 /* file names are case sensitive */
#define FS_NOXBIT 0x04 /* if a file can be read, it can be executed */
#define FS_LONGPATH 0x08 /* file system understands "size" argument to
"getname" */
long ARGS_ON_STACK (*root) P_((int drv, fcookie *fc));
long ARGS_ON_STACK (*lookup) P_((fcookie *dir, const char *name, fcookie *fc));
long ARGS_ON_STACK (*creat) P_((fcookie *dir, const char *name, unsigned mode,
int attrib, fcookie *fc));
DEVDRV * ARGS_ON_STACK (*getdev) P_((fcookie *fc, long *devspecial));
long ARGS_ON_STACK (*getxattr) P_((fcookie *file, XATTR *xattr));
long ARGS_ON_STACK (*chattr) P_((fcookie *file, int attr));
long ARGS_ON_STACK (*chown) P_((fcookie *file, int uid, int gid));
long ARGS_ON_STACK (*chmode) P_((fcookie *file, unsigned mode));
long ARGS_ON_STACK (*mkdir) P_((fcookie *dir, const char *name, unsigned mode));
long ARGS_ON_STACK (*rmdir) P_((fcookie *dir, const char *name));
long ARGS_ON_STACK (*remove) P_((fcookie *dir, const char *name));
long ARGS_ON_STACK (*getname) P_((fcookie *relto, fcookie *dir,
char *pathname, int size));
long ARGS_ON_STACK (*rename) P_((fcookie *olddir, char *oldname,
fcookie *newdir, const char *newname));
long ARGS_ON_STACK (*opendir) P_((DIR *dirh, int tosflag));
long ARGS_ON_STACK (*readdir) P_((DIR *dirh, char *name, int namelen, fcookie *fc));
long ARGS_ON_STACK (*rewinddir) P_((DIR *dirh));
long ARGS_ON_STACK (*closedir) P_((DIR *dirh));
long ARGS_ON_STACK (*pathconf) P_((fcookie *dir, int which));
long ARGS_ON_STACK (*dfree) P_((fcookie *dir, long *buf));
long ARGS_ON_STACK (*writelabel) P_((fcookie *dir, const char *name));
long ARGS_ON_STACK (*readlabel) P_((fcookie *dir, char *name, int namelen));
long ARGS_ON_STACK (*symlink) P_((fcookie *dir, const char *name, const char *to));
long ARGS_ON_STACK (*readlink) P_((fcookie *dir, char *buf, int len));
long ARGS_ON_STACK (*hardlink) P_((fcookie *fromdir, const char *fromname,
fcookie *todir, const char *toname));
long ARGS_ON_STACK (*fscntl) P_((fcookie *dir, const char *name, int cmd, long arg));
long ARGS_ON_STACK (*dskchng) P_((int drv));
long ARGS_ON_STACK (*release) P_((fcookie *));
long ARGS_ON_STACK (*dupcookie) P_((fcookie *new, fcookie *old));
} FILESYS;
/*
* this is the structure passed to loaded file systems to tell them
* about the kernel
*/
struct kerinfo {
short maj_version; /* kernel version number */
short min_version; /* minor kernel version number */
ushort default_perm; /* default file permissions */
short reserved1; /* room for expansion */
/* OS functions */
Func *bios_tab; /* pointer to the BIOS entry points */
Func *dos_tab; /* pointer to the GEMDOS entry points */
/* media change vector */
void ARGS_ON_STACK (*drvchng) P_((unsigned));
/* Debugging stuff */
void ARGS_ON_STACK (*trace) P_((const char *, ...));
void ARGS_ON_STACK (*debug) P_((const char *, ...));
void ARGS_ON_STACK (*alert) P_((const char *, ...));
EXITING void ARGS_ON_STACK (*fatal) P_((const char *, ...));
/* memory allocation functions */
void * ARGS_ON_STACK (*kmalloc) P_((long));
void ARGS_ON_STACK (*kfree) P_((void *));
void * ARGS_ON_STACK (*umalloc) P_((long));
void ARGS_ON_STACK (*ufree) P_((void *));
/* utility functions for string manipulation */
int ARGS_ON_STACK (*strnicmp) P_((const char *, const c